#ifndef DEVICES_H__
#define  DEVICES_H__

#include <io.h>
#include <list.h>
#include <sched.h>
#include <filesystem-structures.h>

// Keyboard
#define KEYBOARD_EFFECTIVE_SIZE 7
// Sempre hi ha una posició en blanc al buffer per distingir els estats buit i ple
// la mida efectiva és la mida real - 1
#define KEYBOARD_BUFFER_SIZE KEYBOARD_EFFECTIVE_SIZE+1 

// Console
int sys_write_console(int fd, char *buffer,int size);
void sys_init_console(struct file_operations* ops);

// Keyboard
char kb_buffer[KEYBOARD_BUFFER_SIZE];
int kb_rd_index;
int kb_wr_index;
int kb_buffered_bytes();
int kb_buffer_full();
int kb_buffer_read(char* buffer, int size);
inline int kb_buffer_write(char c);

int sys_read_keyboard(int, char *buffer, int size);
void sys_init_keyboard(struct file_operations* ops);

// Default
int sys_open_undefined(int fd);
int sys_read_undefined(int fd, char *buffer, int size);
int sys_write_undefined(int fd, char *buffer, int size);
int sys_close_undefined(int fd);
int sys_unlink_undefined(struct file* f);

#endif /* DEVICES_H__*/
